package org.serverct.finalfight.game.hadesgame.events;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.serverct.finalfight.game.hadesgame.EventType;
import org.serverct.finalfight.internal.game.basic.BasicGame;
import org.serverct.finalfight.internal.game.hadesgame.InstantEvent;

import java.util.UUID;

public class CrazyCocktails extends InstantEvent {

    public CrazyCocktails(BasicGame game, EventType type) {
        super(game, type);
    }

    @Override
    public void execute() {
        for (UUID uuid : this.game.players.keySet()) {
            Player player = Bukkit.getPlayer(uuid);
            if (!this.game.isAlive(player)) {
                continue;
            }
            for (PotionEffectType type : PotionEffectType.values()) {
                if (type == null) {
                    continue;
                }
                if (Math.random() < 0.2) {
                    if (type.toString().contains("INSTANT")) {
                        player.addPotionEffect(new PotionEffect(type, 0, 0));
                    } else {
                        player.addPotionEffect(new PotionEffect(type, 300, 0));
                    }
                }
            }
        }
    }
}
